import type { IHttpContext, IHttpResponse } from "boot/interface"
import { Controller, Inject, Get, Post, RequestBody, PathVariable, Response } from "boot/decorator"
import UserService from "../service/UserService"

@Controller("/user")
export default class UserController {
  @Inject()
  userService: UserService

  @Get("/add")
  async addUser(
    // @RequestBody() user: IUserInfo,
    @Response() response: IHttpResponse,
    ctx: IHttpContext
  ) {
    ctx.body = await this.userService.addUser()
  }

  @Get("/find")
  async findUser(
    ctx: IHttpContext
  ) {
    ctx.body = await this.userService.getUser(1)
  }

  @Get("/find/:userId")
  async getUser(
    @PathVariable("userId") userId: number,
    ctx: IHttpContext
  ) {
    ctx.body = this.userService.getUser(userId)
  }

}
